
var NinJaControls={Version:"1.0"};if(typeof(NinJaVisuals)=="undefined"){alert("NinJaControls requires the NinJaVisuals extensions, be prepared for errors.");}
Div.Extensions.Add(new Extension("accordion",Accordion));$Accordion=$AccordionItem=$Anchor;Type.Accordion=Type.$++;Type.AccordionItem=Type.$++;function Accordion(e){if(e===undefined||e.Type==Type.String){e=new Div(e).ClassName("accordion");}
e.__SelectedItem=null;e.__Effect=e.getAttribute("effect")||"none";e.__HeaderClass=e.getAttribute("headerclass")||"header";e.__SelectedClass=e.getAttribute("selectedclass")||"selected";e.__ItemClass=e.getAttribute("itemclass")||"item";e.Items=new ObservableArray();var c=Array.From(e.children);var l=c.length;var v;for(var i=0;i<l;i++){v=c[i];if(v.tagName=="DIV"){AccordionItem(Div(v))
e.Items.Add(v);e.InsertElementBefore(v.Header,v);v.Classes.Add(e.__ItemClass);v.Header.Classes.Add(e.__HeaderClass);v.__Effect=new Effect(v,e.__Effect,1,0,Speed.Normal,Smoothness.Smoothest);}}
NinJa.Extend(e,Accordion);e.Items.OnChange.Add(new Delegate(e.__ItemsChanged,e,Delegate.Event));e.OnSelectionChanged=new Event();e.Type=Type.Accordion;return e;}
Accordion.prototype.__ItemsChanged=function(e){var o=e.Objects,l=o.length,v,i;switch(e.ModificationType){case ModificationType.Add:for(i=0;i<l;i++){v=o[i];this.AddElements([v.Header,v]);v.ClassName(this.__ItemClass).Header.ClassName(this.__HeaderClass);v.__Effect=new Effect(v,this.__Effect,1,0,Speed.Fastest,Smoothness.Normal);}
break;case ModificationType.Remove:case ModificationType.Clear:for(i=0;i<l;i++){v=o[i];this.RemoveElements([v.Header,v]);}
break;case ModificationType.Move:case ModificationType.Swap:case ModificationType.Update:this.RemoveElements(Array.From(this.children));o=this.Items;for(i=0;i<l;i++){v=o[i];this.AddElements([v.Header,v]);}
break;}}
Accordion.prototype.HeaderClass=function(className){if(className===undefined){return this.__HeaderClass;}
this.__HeaderClass=className;var i,a=this.Items,l=a.length;for(i=0;i<l;i++){a[i].Header.ClassName(className);}
return this;}
Accordion.prototype.ItemClass=function(className){if(className===undefined){return this.__ItemClass;}
this.__ItemClass=className;var i,a=this.Items,l=a.length;for(i=0;i<l;i++){a[i].ClassName(className);}
return this;}
Accordion.prototype.SelectedClass=function(className){if(className===undefined){return this.__SelectedClass;}
this.__SelectedClass=className;if(this.__SelectedItem){this.__SelectedItem.ClassName(className);}
return this;}
Accordion.prototype.SelectedItem=function(item){if(item===undefined){return this.__SelectedItem;}
if(this.__SelectedItem){this.__SelectedItem.Header.Classes.Remove(this.__SelectedClass);this.__SelectedItem.__Effect.Reverse();}
this.__SelectedItem=item;if(item!==null){this.__SelectedItem.__Effect.Play();this.__SelectedItem.Header.Classes.Add(this.__SelectedClass);}
if(this.OnSelectionChanged.length>0){this.OnSelectionChanged.Fire(new EventArgs(this));}
return this;}
Accordion.prototype.Effect=function(effect){this.__Effect=effect;var i,a=this.Items,l=a.length,v;for(i=0;i<l;i++){v=a[i];v.__Effect=new Effect(v,this.__Effect,1,0,Speed.Fastest,Smoothness.Normal);}
return this;}
function AccordionItem(e){if(e===undefined||e.Type==Type.String){e=new Div(e);}
var t=e.getAttribute("header");e.Collapsed(true);e.Header=new Div().Cursor(Cursor.Pointer);if(t){e.Header.Text(t);}
t=e.ElementsByClassName("header");if(t[0]){t=$Div(t[0]);t.parentNode.removeChild(t);t.Classes.Remove("header");e.Header.AddElement(t);}
e.__Selected=(e.getAttribute("selected")||"false").ToBoolean()
NinJa.Extend(e,AccordionItem);e.Header.OnClick.Add(new Delegate(e.Toggle,e,"Selected"));e.__Effect=null;e.Type=Type.AccordionItem;return e;}
AccordionItem.prototype.Selected=function(selected){if(selected===undefined){return this.parentNode.__SelectedItem==this;}
if(selected===true){if(this.parentNode.__SelectedItem!=this){this.parentNode.SelectedItem(this);}
return this;}
if(this.parentNode.__SelectedItem==this){this.parentNode.SelectedItem(null);}
return this;}
Type.Calendar=Type.$++;$Calendar=$Anchor;TextBox.Extensions.Add(new Extension("calendar",Calendar));function Calendar(e){if(e===undefined||e.Type==Type.String){e=new TextBox(e);}
e.Classes.Remove("calendar");var t,a,i,v,l,b;e.__Display=new Div().Position("absolute").Collapsed(true);t=e.__Table=new Table().ClassName("calendar").CellPadding(0).CellSpacing(0).Style(Style.TableLayout,"fixed");t.SetHead(new TableHead());e.__Display.AddElement(t);e.__PadClass=e.getAttribute("padclass")||"pad";e.__PadDays=(e.getAttribute("pad")||"false").ToBoolean();e.__Selected=e.getAttribute("selectedclass")||"selected";e.__Effect=new Effect(e.__Display,e.getAttribute("effect")||"none",1,0,Speed.Fastest,Smoothness.Normal);e.__CS=null;NinJa.Extend(e,Calendar);var d=e.Text();if(d&&d.IsDate()){d=new DateTime(d);}
else{d=DateTime.Now();}
e.__D=d.Date();e.__M=d.Month();e.__Y=d.Year();var prev=new Anchor().Href("javascript: Null();").Text("<");var next=new Anchor().Href("javascript: Null();").Text(">");prev.tabIndex=next.tabIndex=1000000;t.Head.Rows.Add(new Row().HorizontalAlignment("center"));t.Head.Rows[0].Cells.AddRange([new Cell().AddElement(prev),new Cell().ColumnSpan(5),new Cell().AddElement(next)]);t.Rows.Add(new Row().HorizontalAlignment("center"));t.Rows[0].Cells.AddRange([new Header().Text("S"),new Header().Text("M"),new Header().Text("T"),new Header().Text("W"),new Header().Text("T"),new Header().Text("F"),new Header().Text("S")]);if(e.onselectstart!==undefined){e.onselectstart=function(e){return false;};}
else{e.OnClick.Add(function(e){e.Handled=true;e.CancelEvent=true;});}
NinJa.Extend(e,Calendar);b=[];d=new Delegate(e.__DateSelected,e,Delegate.Event);for(i=0;i<6;i++){a=[new Cell(),new Cell(),new Cell(),new Cell(),new Cell(),new Cell(),new Cell()];for(l=0;l<7;l++){a[l].OnClick.Add(d);}
v=new Row().HorizontalAlignment("center");v.Cells.AddRange(a);b.Add(v);}
t.Rows.AddRange(b);prev.OnClick.Add(new Delegate(e.__ChangeMonth,e,-1));next.OnClick.Add(new Delegate(e.__ChangeMonth,e,1));e.OnFocus.Add(new Delegate(e.Show,e));e.OnClick.Add(new Delegate(e.Show,e));e.OnBlur.Add(new Delegate(e.Hide,e));e.OnKeyUp.Add(new Delegate(e.Update,e));Page.OnClick.Add(new Delegate(e.Hide,e));Page.AddElement(e.__Display);e.Refresh();return e;};Calendar.prototype.__ChangeMonth=function(change){var m=this.__M+change;if(m==0){m=12;this.__Y--;}
else if(m==13){m=1;this.__Y++;}
this.__M=m;this.Refresh();};Calendar.prototype.__DateSelected=function(e){var t=e.Sender.Tag,s=e.Sender;if(t<0){return;}
this.__D=t;if(this.__CS){this.__CS.ClassName("");}
this.__CS=s;s.ClassName(this.__Selected);this.Text(new DateTime(this.__Y,this.__M,this.__D));this.Focus();this.Hide(true);};Calendar.prototype.Effect=function(effect){this.__Effect=new Effect(this.__Display,effect,1,0,Speed.Fastest,Smoothness.Normal);return this;}
Calendar.prototype.PadDays=function(padDays){if(padDays===undefined){return this.__PadDays;}
this.__PadDays=padDays;this.Refresh();return this;}
Calendar.prototype.Show=function(){if(this.__Forced){this.__Forced=false;return;}
if(!this.__Display.Collapsed()){return;}
this.__Display.X(this.X()).Y(this.Y()+this.LayoutHeight());this.__Effect.Play();};Calendar.prototype.Hide=function(forced){if((this.IsFocused||this.__Display.IsMouseOver)&&!forced){return;}
if(this.__Display.Collapsed()){return;}
this.__Forced=forced;this.__Effect.Reverse();};Calendar.prototype.Update=function(){var t=this.Text();if(t.IsDate()){var d=t.ToDateTime();this.__D=d.Date();this.__M=d.Month();this.__Y=d.Year();this.Refresh();}};Calendar.prototype.SelectedDate=function(date){if(date===undefined){var t=this.Text();if(t.IsDate()){return t.ToDateTime();}}
if(date==null){this.Text("");}
else{this.Text(date.ToString());}
this.Refresh();return this;}
Calendar.prototype.Pad=function(pad){if(pad===undefined){return this.__PadDays;}
this.__PadDays=pad;this.Refresh();return this;}
Calendar.prototype.PadClass=function(padClass){if(padClass===undefined){return this.__PadClass;}
this.__PadClass=padClass;this.Refresh();return this;};Calendar.prototype.SelectedClass=function(selectedClass){if(selectedClass===undefined){return this.__Selected;}
this.__Selected=selectedClass;this.Refresh();return this;};Calendar.prototype.Refresh=function(){this.__Display.firstChild.Head.Rows[0].Cells[1].Text(DateTime.Months.GetName(this.__M)+" "+this.__Y);var tb=this.__Display.firstChild.Body;var r=1;var d=new DateTime(this.__Y,this.__M,1);var D=d.Date(),M=d.Month(),Y=d.Year();var Mx=DateTime.Months.GetDays(this.__M,this.__Y)+1;var cDow=DateTime.Days.Sunday,dow=d.DayOfWeek();var i,j,c=tb.Rows[r],e=1;var cD=d.Subtract(new TimeSpan(24*dow-cDow,0));for(i=0;i<dow;i++){if(this.__PadDays){c.Cells[i].Text(cD.Date()+i).ClassName(this.__PadClass).Tag=-1;}
else{c.Cells[i].Text("").ClassName(this.__PadClass).Tag=-1;}}
var brk=false;for(j=r;j<8;){c=tb.Rows[r];c.Collapsed(false);for(;i<7;i++){c.Cells[i].Text(e).ClassName(this.__D==e?this.__Selected:"").Tag=e;if(this.__D==e){this.__CS=c.Cells[i];}
e++;if(e>Mx){brk=true;break;}}
if(brk){break;}
else{i=0;j++,r++;}}
e=1;while(j<7){c=tb.Rows[r];if(i==0){c.Collapsed(true);}
else{for(;i<7;i++,e++){if(this.__PadDays){c.Cells[i].Text(e).ClassName(this.__PadClass).Tag=-1;}
else{c.Cells[i].Text("").ClassName(this.__PadClass).Tag=-1;}}}
i=0;j++;r++;}};var DialogResult=LazyEnum({Ok:0,Cancel:1,Yes:2,No:3});Div.Extensions.Add(new Extension("dialog",Dialog));var $Dialog=$Anchor;function Dialog(e){if(e===undefined||e.Type==Type.String){e=new Div(e).ClassName("dialog");}
e.__Effect1=new Effect(Dialog.Filter,e.getAttribute("effect")||"none",Dialog.Opacity,0,Speed.Faster,Smoothness.Smoother);e.__Effect2=new Effect(Dialog.Filter.T,e.getAttribute("effect")||"none",1,0,Speed.Faster,Smoothness.Smoother);NinJa.Extend(e,Dialog);if(e.parentNode){e.parentNode.removeChild(e);};Dialog.Dialogs.AddElement(e);e.OnDialogClose=new Event(e);e.Result=null;return e;}
Dialog.CurrentDialog=null,Dialog.Color="black",Dialog.Opacity=.5,Dialog.ZIndex=100000,Dialog.Filter=null;Dialog.RemoveCurrent=function(data){Dialog.Filter.T.Rows[0].Cells[0].RemoveElement(Dialog.CurrentDialog);Dialog.Dialogs.AddElement(Dialog.CurrentDialog);}
Dialog.Hide=function(data){var d=Dialog.CurrentDialog;if(d){d.Result=data;if(d.OnDialogClose.Fire(new EventArgs(d,data))!=false){d.__Effect1.Reverse(Dialog.RemoveCurrent);d.__Effect2.Reverse();Dialog.CurrentDialog=null;}}}
Dialog.prototype.Show=function(){if(Dialog.CurrentDialog){Dialog.RemoveCurrent();}
Dialog.CurrentDialog=this;Dialog.Dialogs.RemoveElement(this);Dialog.Filter.T.Rows[0].Cells[0].AddElement(this);this.__Effect1.Play();this.__Effect2.Play();};Dialog.prototype.Hide=function(data){Dialog.RemoveCurrent(data);};NinJa.OnInitialization.Add(function(){Dialog.Dialogs=new Div().Collapsed(true);Page.AddElement(Dialog.Dialogs);Dialog.Filter=new Div().BackgroundColor(Dialog.Color).Width("100%").Height("100%").Style(Style.ZIndex,Dialog.ZIndex).Position("fixed").X(0).Y(0).Collapsed(true);Dialog.Filter.T=new Table().Width("100%").Height("100%").Style(Style.ZIndex,Dialog.ZIndex+1).Position("fixed").X(0).Y(0).Collapsed(true);Dialog.Filter.T.Rows.Add(new Row().Height("100%"));Dialog.Filter.T.Rows[0].Cells.Add(new Cell().HorizontalAlignment("center").VerticalAlignment("middle").Height("100%"));Dialog.Filter.AddElement(Dialog.Dialogs);Dialog.Filter.Opacity(Dialog.Opacity);Page.AddElement(Dialog.Filter);Page.AddElement(Dialog.Filter.T);});Type.FormColumn=Type.$++;Type.FormTable=Type.$++;Table.Extensions.Add(new Extension("form",FormTable));function FormTable(e){e.__HighlightClass=e.getAttribute("highlight")||"";NinJa.Extend(e,FormTable);if(e.__HighlightClass){var inputs=Array.From(e.getElementsByTagName("input")).AddRange(e.getElementsByTagName("select")).AddRange(e.getElementsByTagName("textarea"));var v;var l=inputs.length;for(var i=0;i<l;i++){v=$Input(inputs[i]);v.OnFocus.Add(new Delegate(e.__Highlight,e,v,true));v.OnBlur.Add(new Delegate(e.__Highlight,e,v,false));}
inputs=e.getElementsByTagName("select");l=inputs.length;for(var i=0;i<l;i++){v.OnFocus.Add(new Delegate(e.__Highlight,e,v,true));v.OnBlur.Add(new Delegate(e.__Highlight,e,v,false));}
inputs=e.getElementsByTagName("textarea");l=inputs.length;for(var i=0;i<l;i++){v.OnFocus.Add(new Delegate(e.__Highlight,e,v,true));v.OnBlur.Add(new Delegate(e.__Highlight,e,v,false));}}
e.ColumnGroups=new ObservableArray();var o=Array.From(e.children);var l=o.length;var v;for(var i=0;i<l;i++){v=o[i];if(v.tagName=="COLGROUP"){e.ColumnGroups.Add(ColumnGroup(v));}}
e.__ApplyStyling();e.Type=Type.FormTable;return e;}
function ColumnGroup(e){e.FormColumns=new ObservableArray();e.FormRow=null;var a=e.children;var l=a.length;for(var i=0;i<l;i++){e.FormColumns.Add(FormColumn(a[i]));}
return e;}
FormTable.prototype.__ApplyStyling=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;b=this.ColumnGroups;c=this.Bodies;d=c.length;for(e=0;e<d;e++){f=c[e]
g=f.Rows;h=g.length;i=0;for(j=0;j<h;j++){k=b[i];if(k===undefined){continue;}
l=g[j].Cells;m=l.length
for(n=0;n<m;n++){o=l[n];if(o.colSpan==1){p=k.FormColumns[n];if(p){o.setAttribute("valign",p.__VAlign);o.setAttribute("align",p.__HAlign);o.setAttribute("width",p.__Width);o.setAttribute("style",p.__Style);o.ClassName(p.__Class);}}}}}}
FormTable.prototype.__Highlight=function(element,value){var row=element;while((row.Type!=Type.Row&&row.Type!=Type.Body)||row.parentNode.parentNode!=this){row=row.parentNode;}
if(row.Type!=Type.Row){return;}
if(value===true){row.Classes.Add(this.__HighlightClass);}
else{row.Classes.Remove(this.__HighlightClass);}};function FormColumn(e){e.__VAlign=e.getAttribute("valign")||"";e.__HAlign=e.getAttribute("align")||"";e.__Style=e.getAttribute("style")||"";e.__Class=e.getAttribute("class")||"";e.__Width=e.getAttribute("width")||"";NinJa.Extend(e,FormColumn);e.Type=Type.FormColumn
return e;}
Div.Extensions.Add(new Extension("grid",Grid));Type.Grid="Grid";Type.GridRow="GridRow";Type.GridCell="GridCell";Type.GridColumns="GridColumns";$Grid=$GridRow=$GridCell=$Anchor;function Grid(e){if(e===undefined||e.Type==Type.String){e=new Div(e).ClassName("grid");}
NinJa.Extend(e,Grid);e.Rows=[];e.__Calculating=false;var c=e.children;var l=c.length;for(var i=0;i<l;i++){e.Rows.Add(GridRow(c[i]));}
var d=new Delegate(e.__CalculateRows,e);Client.OnResize.Add(d);Page.OnLoad.Add(d);e.__NativeWidth=Element.prototype.Width;e.__NativeHeight=Element.prototype.Height;e.Type=Type.Grid;e.Style(Style.BoxSizing,"border-box");return e;}
Grid.prototype.Width=function(width){if(width===undefined){return this.__NativeWidth(width);}
this.__NativeWidth(width);this.__CalculateRows();}
Grid.prototype.Height=function(height){if(height===undefined){return this.__NativeHeight(height);}
this.__NativeHeight(height);this.__CalculateRows();}
Grid.prototype.__CalculateRows=function(){this.__Calculating=true;var static=[];var relative=[];var liquid=[];var r=this.Rows;var l=r.length;var v;for(var i=0;i<l;i++){v=r[i];switch(v.__Height.ColumnsType){case GridColumnsType.Static:static.Add(v);break;case GridColumnsType.Relative:relative.Add(v);break;case GridColumnsType.Liquid:liquid.Add(v);break;}}
var fullH=totalH=this.Height();var h;l=static.length;this.Collapsed(true);for(i=0;i<l;i++){v=static[i];h=v.__Height.Value;v.__NativeHeight(h);totalH-=h;}
l=relative.length;for(i=0;i<l;i++){v=relative[i];h=fullH*(v.__Height.Value/100)
v.__NativeHeight(h);totalH-=h;};var rest=totalH/liquid.length;l=liquid.length;for(i=0;i<l;i++){v=liquid[i];v.__NativeHeight(rest);}
this.Collapsed(false);l=r.length;for(i=0;i<l;i++){r[i].__CalculateCells();}
this.__Calculating=false;}
function GridRow(e){if(e===undefined||e.Type==Type.String){e=new Div(e);e.Classes.Add("row");}
$Div(e);if(!e.Classes.Contains("row")){return;}
e.__Height=new GridMeasure("*");e.__Calculating=false;var a=e.getAttribute("gridheight");if(a){e.__Height=new GridColumns(a);}
NinJa.Extend(e,GridRow);e.Cells=[];var c=e.children;var l=c.length;for(var i=0;i<l;i++){e.Cells.Add(GridCell(c[i]));}
e.__NativeHeight=Element.prototype.Height;e.Type=Type.GridRow;e.Style(Style.BoxSizing,"border-box");return e;}
GridRow.prototype.Height=function(height){if(height===undefined){return this.__NativeHeight(height);}
this.__Height=new GridMeasure(height);var e=this.parentNode;if(!e.__Calculating){e.__CalculateRows();}
e.__CalculateCells();}
GridRow.prototype.__CalculateCells=function(){this.__Calculating=true;var static=[];var relative=[];var liquid=[];var c=this.Cells;var l=c.length;var v;for(var i=0;v=c[i++];){switch(v.__Width.ColumnsType){case GridColumnsType.Static:static.Add(v);break;case GridColumnsType.Relative:relative.Add(v);break;case GridColumnsType.Liquid:liquid.Add(v);break;}}
var fullW=totalW=this.Width();var w;this.Collapsed(true);l=static.length;for(i=0;i<l;i++){v=static[i];w=v.__Width.Value;v.__NativeWidth(w);totalW-=w;}
l=relative.length;for(i=0;i<l;i++){v=relative[i];w=fullW*(v.__Width.Value/100)
v.__NativeWidth(w);totalW-=w;}
var rest=totalW/liquid.length;l=liquid.length;for(i=0;i<l;i++){v=liquid[i];v.__NativeWidth(rest);}
this.Collapsed(false);this.__Calculating=false;}
function GridCell(e){if(e===undefined||e.Type==Type.String){e=new Div(e);e.Classes.Add("cell");}
$Div(e);if(!e.Classes.Contains("cell")){return;}
e.__Width=new GridMeasure("*");;var a=e.getAttribute("gridwidth");if(a){e.__Width=new GridColumns(a);}
NinJa.Extend(e,GridCell);e.Style("box-sizing","border-box");e.Style(Style.Display,"inline-block");e.Style(Style.Zoom,"1");e.Style(Style.Float,"left");e.Style(Style.Overflow,"hidden");e.__NativeWidth=Element.prototype.Width;e.Type=Type.GridCell;e.Height("100%");e.Style(Style.BoxSizing,"border-box");return e;}
GridCell.prototype.Width=function(width){if(width===undefined){return this.__NativeWidth(width);}
this.__Width=new GridMeasure(width);var e=this.parentNode;if(!e.__Calculating){e.__CalculateCells();}}
var GridColumnsType={Static:0,Relative:1,Liquid:2};function GridMeasure(value){this.Value=null;this.ColumnsType=GridColumnsType.Liquid;this.Type=Type.GridColumns;switch(value.Type){case Type.String:if(value.EndsWith("%")){this.Value=value.Remove("%").ToInt();this.ColumnsType=GridColumnsType.Relative;}
else if(value=="*"){this.Value=null;this.ColumnsType=GridColumnsType.Liquid;}
else if(value.IsInt()){this.Value=value.ToInt();this.ColumnsType=GridColumnsType.Static;}
break;case Type.Number:this.Value=value;this.ColumnsType=GridColumnsType.Static;break;}}
Anchor.Extensions.Add(new Extension("oneclick",OneClickAnchor));Button.Extensions.Add(new Extension("oneclick",OneClickButton));ContentButton.Extensions.Add(new Extension("oneclick",OneClickContentButton));function OneClickAnchor(e){if(e===undefined||e.Type==Type.String){e=new Anchor(e).ClassName("oneclick");}
e.OnClick.Add(new Delegate(e.Enabled,e,false));return e;}
function OneClickButton(e){if(e===undefined||e.Type==Type.String){e=new Button(e).ClassName("oneclick");}
e.OnClick.Add(new Delegate(e.Enabled,e,false));return e;}
function OneClickContentButton(e){if(e===undefined||e.Type==Type.String){e=new ContentButton(e).ClassName("oneclick");}
e.OnClick.Add(new Delegate(e.Enabled,e,false));return e;}
ImageElement.Extensions.Add(new Extension("rollover",RollOverImage));$RollOverImage=$TextBox;function RollOverImage(e){if(e===undefined||e.Type===Type.String){e=new ImageElement(e).ClassName("rollover");}
e.__H=e.getAttribute("hover")||"";e.__MOv=new Delegate(e.Source,e,e.__H)
e.__MOu=new Delegate(e.Source,e,e.src)
if(e.__H!=null){e.OnMouseOver.Add(e.__MOv);e.OnMouseOut.Add(e.__MOu);}
e.__OS=ImageElement.prototype.Source;NinJa.Extend(e,RollOverImage);return e;}
RollOverImage.prototype.Source=function(src){if(src===undefined){return this.__MOu.Parameters[0];}
this.__MOu.Parameters[0]=src;if(!this.IsMouseOver){this.src=src;}
return this;}
RollOverImage.prototype.HoverSource=function(src){if(src===undefined){return this.__MOv.Parameters[0];}
this.__MOv.Parameters[0]=src;if(this.IsMouseOver){this.src=src;}
return this;}
Type.ScrollBar=Type.$++;Div.Extensions.Add(new Extension("scrollbar",ScrollBar));$ScrollBar=$TextBox;function ScrollBar(e){if(e===undefined||e.Type===Type.String){e=new Div(e).ClassName("scrollbar");}
e.__Orient=e.getAttribute("direction")||"vertical";var w,h;w=e.getAttribute("swidth")||e.__Orient=="horizontal"?"100":"15";h=e.getAttribute("sheight")||e.__Orient=="horizontal"?"15":"100";e.ClearTextNodes();e.Style(Style.Display,"inline-block").Style(Style.BoxSizing,"border-box");e.NaturalDisplay="inline-block";if(w){e.Width(w.ToInt());}
if(h){e.Height(h.ToInt());}
var a=e.ElementsByClassName("decrease");if(a[0]){e.DecreaseThumb=new DecreaseThumb(a[0]).ClassName("decrease thumb");}
else{e.DecreaseThumb=new DecreaseThumb(new Div()).ClassName("decrease thumb");e.AddElement(e.DecreaseThumb);}
a=e.ElementsByClassName("increase");if(a[0]){e.IncreaseThumb=new IncreaseThumb(a[0]).ClassName("increase thumb");}
else{e.IncreaseThumb=new IncreaseThumb(new Div()).ClassName("increase thumb");e.AddElement(e.IncreaseThumb);}
a=e.ElementsByClassName("track");if(a[0]){e.TrackThumb=new TrackThumb(a[0]).ClassName("track thumb");e.RemoveElement(e.TrackThumb);}
else{e.TrackThumb=new TrackThumb(new Div()).ClassName("track thumb");}
e.Track=new Div().Style(Style.BoxSizing,"border-box");e.InsertElement(1,e.Track);e.Track.AddElement(e.TrackThumb);e.__Value=0;if(e.__Orient=="horizontal"){e.IncreaseThumb.Style(Style.Display,"inline-block");e.DecreaseThumb.Style(Style.Display,"inline-block");e.Track.Style(Style.Display,"inline-block").Height("100%");e.IncreaseThumb.Width(16).Height("100%");e.DecreaseThumb.Width(16).Height("100%");e.TrackThumb.Height("100%");}
else{e.IncreaseThumb.Width(15).Height(16);e.DecreaseThumb.Width(15).Height(16);}
var max=(e.getAttribute("maxvalue")||"10").ToInt();e.__Width=e.Width;e.__Height=e.Height;NinJa.Extend(e,ScrollBar);e.Track.OnMouseWheel.Add(new Delegate(e.__HandleScroll,e,Delegate.Event));e.Track.OnClick.Add(new Delegate(e.__HandleTrackClick,e,Delegate.Event));e.DecreaseThumb.OnClick.Add(new Delegate(e.Decrease,e));e.IncreaseThumb.OnClick.Add(new Delegate(e.Increase,e));e.__RefreshView();e.MaxValue(max);e.OnScrollChange=new Event();e.Type=Type.ScrollBar;return e;}
ScrollBar.prototype.__HandleScroll=function(e){this.Value(this.__Value+e.Clicks);e.Handled=true;};ScrollBar.prototype.__HandleTrackClick=function(e){if(this.__Orient=="horizontal"){var x=Mouse.X-this.Track.X();if(x<this.TrackThumb.X()){this.Value(this.__Value-this.TrackThumb.LayoutWidth());}
else{this.Value(this.__Value+this.TrackThumb.LayoutWidth());}}else{var y=Mouse.Y-this.Track.Y();if(y<this.TrackThumb.Y()){this.Value(this.__Value-this.TrackThumb.LayoutHeight());}
else{this.Value(this.__Value+this.TrackThumb.LayoutHeight());}}};ScrollBar.prototype.Width=function(width){if(width===undefined){return this.__Width(width);}
this.__Width(width);this.__RefreshView();this.MaxValue(this.__MaxValue);return this;};ScrollBar.prototype.Height=function(height){if(height===undefined){return this.__Width(height);}
this.__Height(height);this.__RefreshView();this.MaxValue(this.__MaxValue);return this;};ScrollBar.prototype.MaxValue=function(maxValue){if(maxValue==undefined){return this.__MaxValue;}
var h;maxValue=maxValue<0?0:maxValue;this.__MaxValue=maxValue;if(this.__Orient=="horizontal"){h=this.Track.LayoutWidth()-maxValue;if(h<8){this.TrackThumb.Width(8);this.__Step=(this.Track.LayoutWidth()-8)/maxValue;}
else{this.TrackThumb.Width(h);this.__Step=1;}}
else{h=this.Track.LayoutHeight()-maxValue;if(h<8){this.TrackThumb.Height(8);this.__Step=(this.Track.LayoutHeight()-8)/maxValue;}
else{this.TrackThumb.Height(h);this.__Step=1;}}
if(this.__Value>this.__MaxValue){this.__Value=this.__MaxValue;}
this.Refresh();};ScrollBar.prototype.Refresh=function(){if(this.__Orient=="horizontal"){this.TrackThumb.X(this.__Step*this.__Value);}
else{this.TrackThumb.Y(this.__Step*this.__Value);}};ScrollBar.prototype.__RefreshView=function(){if(this.__Orient=="horizontal"){this.Track.Width(this.LayoutWidth()-(this.DecreaseThumb.LayoutWidth()+this.IncreaseThumb.LayoutWidth()));}
else{this.Track.Height(this.LayoutHeight()-(this.DecreaseThumb.LayoutHeight()+this.IncreaseThumb.LayoutHeight()));}};ScrollBar.prototype.Value=function(value){if(value===undefined){return this.__Value;}
this.__Value=value>this.__MaxValue?this.__MaxValue:(value<0?0:value);this.OnScrollChange.Fire(new EventArgs(this,this.__Value));this.Refresh();return this;};ScrollBar.prototype.Decrease=function(){this.Value(this.__Value-1);return this;}
ScrollBar.prototype.Increase=function(){this.Value(this.__Value+1);return this;}
function DecreaseThumb(e){e.Style(Style.BoxSizing,"border-box");return e;}
function TrackThumb(e){e.Style(Style.BoxSizing,"border-box").Position("relative");NinJa.Extend(e,TrackThumb);e.OnMouseDown.Add(new Delegate(e.CaptureMove,e));e.TrackDelegate=new Delegate(e.Move,e);e.TrackDelegate.Enabled=false;e.OnClick.Add(function(e){e.Handled=true;});Page.OnMouseMove.Add(e.TrackDelegate);Page.OnMouseUp.Add(new Delegate(e.LoseMove,e));return e;}
TrackThumb.prototype.CaptureMove=function(){NinJa.Event.Handled=true;this.__X=this.X();this.__Y=this.Y();this.TrackDelegate.Enabled=true;this.Classes.Add("focus");};TrackThumb.prototype.LoseMove=function(){this.TrackDelegate.Enabled=false;this.Classes.Remove("focus");};TrackThumb.prototype.Move=function(){var s=this.parentNode.parentNode;if(s.__Orient=="horizontal"){var x=this.__X+=Mouse.XChange;var v=x/s.__Step;s.Value(v.Round());}
else{var y=this.__Y+=Mouse.YChange;var z=y/s.__Step;s.Value(z.Round());}};function IncreaseThumb(e){e.Style(Style.BoxSizing,"border-box");return e;}
$SuggestionBox=$TextBox;TextBox.Extensions.Add(new Extension("suggestion",SuggestionBox));Type.SuggestionBox=Type.$++;function SuggestionBox(e){if(e===undefined||e.Type==Type.String){e=new TextBox(e).ClassName("suggestion");}
e.setAttribute("autocomplete","off");e.__Display=new Div().Position("absolute").Collapsed(true);e.__Class=e.getAttribute("displayclass")||"";e.__FocusClass=(e.getAttribute("focusclass")||"");e.__Source=e.getAttribute("source")||null;e.__MinLength=(e.getAttribute("minlength")||"3");e.__Text=(e.getAttribute("bindtext")||"");e.__Value=(e.getAttribute("bindvalue")||"");e.__AnchorCache=[];e.__CurrentAnchors=[];e.__CurrentAnchor=null;e.__StopShow=false;e.OnSuggestionSelected=new Event();if(e.__Source){e.__Source=window[e.__Source];}
Page.AddElement(e.__Display);e.__Display.Style("overflow-y","auto");e.__Display.Style("overflow-x","hidden");e.Data=new Array(20);NinJa.Extend(e,SuggestionBox);e.DisplayClass(e.__Class);var d=new Delegate(e.__HandleKeyDown,e,Delegate.Event)
e.__ScrollDel=new Delegate(e.__FixScroll,e,Delegate.Event);e.__Display.OnKeyDown.Add(d);e.__CheckCache();e.Data=new ObservableArray();e.OnFocus.Add(new Delegate(e.__HandleKeyUp,e));e.OnBlur.Add(new Delegate(e.HideSuggestions,e));e.OnKeyDown.Add(d);e.OnKeyUp.Add(new Delegate(e.__HandleKeyUp,e,Delegate.Event));e.OnClick.Add(new Delegate(e.__MuffleClick,e,Delegate.Event));Page.OnClick.Add(new Delegate(e.HideSuggestions,e));e.Type=Type.SuggestionBox;return e;}
SuggestionBox.prototype.__MuffleClick=function(e){e.Handled=true;};SuggestionBox.prototype.__CheckCache=function(){var a;while(this.Data.length>this.__AnchorCache.length){a=new Anchor().Style(Style.Display,"block").Underline(false);a.OnClick.Add(new Delegate(this.__SetText,this,a));this.__AnchorCache.Add(a);}};SuggestionBox.prototype.__HandleKeyDown=function(e){e=$KeyEventArgs(e);switch(e.Key){case Keys.Enter:case Keys.Tab:if(this.__CurrentAnchor){this.__SetText(this.__CurrentAnchor);e.Handled=true;}
break;case Keys.DownArrow:if(this.__Display.Collapsed()){this.ShowSuggestions();}
this.__HighlightNext();break;case Keys.UpArrow:if(this.__Display.Collapsed()){this.ShowSuggestions();}
this.__HighlightPrevious();break;}};SuggestionBox.prototype.__HandleKeyUp=function(e){if(this.__StopShow){this.__StopShow=false;return;}
if(e&&(e.Key==Keys.UpArrow||e.Key==Keys.DownArrow)){return;}
if(this.Text().length>=this.__MinLength){this.Update()
if(this.Data.length>0){this.ShowSuggestions();}
else{this.HideSuggestions(true);}}else{this.Bind([]);this.HideSuggestions(true);}};SuggestionBox.prototype.__SetText=function(a){if(this.__Value){this.Text(NinJa.EvalBind(this.__Value,a.Tag));}
else{this.Text(NinJa.EvalBind(this.__Text,a.Tag));}
this.OnSuggestionSelected.Fire(new EventArgs(this,a.Tag));this.HideSuggestions(true);this.__StopShow=true;this.Update();this.FocusNext();};SuggestionBox.prototype.__HighlightNext=function(){if(this.__Display.Collapsed()){return;}
if(this.__CurrentAnchor){if(this.__FocusClass){this.__CurrentAnchor.Classes.Remove(this.__FocusClass);}
else{this.__CurrentAnchor.BackgroundColor("").ForegroundColor("");}}
var i=this.__CurrentAnchors.IndexOf(this.__CurrentAnchor);i++;if(i>=this.__CurrentAnchors.length){i=0;}
else if(i==-1){i=0;}
this.__CurrentAnchor=this.__CurrentAnchors[i];if(this.__FocusClass){this.__CurrentAnchor.Classes.Add(this.__FocusClass);}
else{this.__CurrentAnchor.BackgroundColor("#3399ff").ForegroundColor("#ffffff");}
if(this.__Display.ElementClipped(this.__CurrentAnchor)){this.__Display.VerticalScrollToElement(this.__CurrentAnchor);}};SuggestionBox.prototype.__HighlightPrevious=function(){if(this.__Display.Collapsed()){return;}
if(this.__CurrentAnchor){if(this.__FocusClass){this.__CurrentAnchor.Classes.Remove(this.__FocusClass);}
else{this.__CurrentAnchor.BackgroundColor("").ForegroundColor("");}}
var i=this.__CurrentAnchors.IndexOf(this.__CurrentAnchor);i--;if(i<0){i=this.__CurrentAnchors.length-1;}
this.__CurrentAnchor=this.__CurrentAnchors[i];if(this.__FocusClass){this.__CurrentAnchor.Classes.Add(this.__FocusClass);}
else{this.__CurrentAnchor.BackgroundColor("#3399ff").ForegroundColor("#ffffff");}
if(this.__Display.ElementClipped(this.__CurrentAnchor)){this.__Display.VerticalScrollToElement(this.__CurrentAnchor);}};SuggestionBox.prototype.DisplayClass=function(className){if(className===undefined){return this.__Display.ClassName();}
this.__Display.ClassName(className);if(!className){this.__Display.Style(Style.Border,"1px solid #000000").BackgroundColor(Colors.White).Height(200);}
else{this.__Display.Style(Style.Border,"").BackgroundColor(Colors.Empty).Style(Style.Padding,"");}
return this;}
SuggestionBox.prototype.FocusClass=function(className){if(className===undefined){return this.__FocusClass;}
this.__FocusClass=className;return this;}
SuggestionBox.prototype.Source=function(source){if(source===undefined){this.__Source=source;}
this.__Source=source;return this;}
SuggestionBox.prototype.MinLength=function(minLength){if(minLength===undefined){return this.__MinLength;}
this.__MinLength=minLength;return this;}
SuggestionBox.prototype.ShowSuggestions=function(){if(!this.__StopShow){if(this.Data.length>0){this.__Display.X(this.X()).Y(this.Y()+this.LayoutHeight());this.__Display.Width("").Collapsed(false).Width(this.__Display.LayoutWidth()+17);}}
return this;};SuggestionBox.prototype.HideSuggestions=function(forced){if(forced===undefined){if(this.__Display.IsMouseOver){return;}}
this.__Display.Collapsed(true);return this;};SuggestionBox.prototype.Update=function(){var data;if(this.__Source){data=this.__Source(this.Text());if(data){this.Bind(data);}}
if(this.__CurrentAnchor){if(this.__FocusClass){this.__CurrentAnchor.Classes.Remove(this.__FocusClass);}
else{this.__CurrentAnchor.BackgroundColor("").ForegroundColor("");}
this.__CurrentAnchor=null;}
return this;}
SuggestionBox.prototype.Bind=function(data){this.Data.BeginUpdate();this.Data.Clear();this.Data.AddRange(data);this.Data.EndUpdate();this.__CheckCache();this.Refresh();this.ShowSuggestions();return this;};SuggestionBox.prototype.BindText=function(text){if(text===undefined){return this.__Text;}
this.__Text=text;return this;}
SuggestionBox.prototype.BindValue=function(value){if(value===undefined){return this.__Value;}
this.__Value=value;return this;}
SuggestionBox.prototype.Refresh=function(){this.__Display.ClearContent();this.__CurrentAnchors.Clear();var l=this.Data.length;var d=this.Data;var a,v;var text=this.__Text;var value=this.__Value;for(var i=0;i<l;i++){v=d[i];a=this.__AnchorCache[i];a.Classes.Clear();a.Text(NinJa.EvalBind(this.__Text,v));a.Tag=v;this.__Display.AddElement(a);this.__CurrentAnchors.Add(a);}};$Template=$Anchor;Type.Template=Type.$++;Div.Extensions.Add(new Extension("template",Template));function Template(e){NinJa.Extend(e,Template);e.Bind(null);return e;}
Template.prototype.Bind=function(obj){obj=obj||{};if(!this.Template){this.Template=true;this.__all=NinJaControls.__GetAllNodes(this,[]);this.__nodeValues=[];var k=this.__all.length;for(var j=0;j<k;j++){this.__nodeValues.push(this.__all[j].nodeValue);}}
var reg=/\{[A-Za-z\.]*}/i,property,a,b,k,v,w,x,y,l=this.__all.length;for(var i=0;i<l;i++){v=this.__nodeValues[i];w=this.__all[i];w.nodeValue=String.BindFormat(v,obj);}
this.Type=Type.Template;};NinJaControls.__GetAllNodes=function(e,array){var a=e.childNodes;var l=a.length;var v;for(var i=0;i<l;i++){v=a[i];if(v.nodeName!="#text"){var b=v.attributes,m=b.length;for(var j=0;j<m;j++){if(String.BindRegEx.exec(b[j].value)){array.push(b[j]);break;}}}
else{if(String.BindRegEx.exec(v.nodeValue)){array.push(v);}}
NinJaControls.__GetAllNodes(v,array);}
return array;}
TextBox.Extensions.Add(new Extension("watermark",WaterMarkTextBox));$WaterMarkTextBox=$TextBox;Type.WaterMarkTextBox=Type.$++;function WaterMarkTextBox(e){if(e===undefined||e.Type==Type.String){e=new TextBox(e).ClassName("watermark");}
e.__OStyle=e.getAttribute("style")|"";e.__OClass=e.className;e.__WaterMarkValue=e.getAttribute("WaterMarkvalue")||"";e.__WaterMarkClass=(e.getAttribute("WaterMarkclass")||"");e.__WaterMarkStyle=e.getAttribute("WaterMarkstyle")||"";if(!e.__WaterMarkClass&&!e.__WaterMarkStyle){e.__WaterMarkStyle="color: #c0c0c0;";}
NinJa.Extend(e,WaterMarkTextBox);e.OnBlur.Add(WaterMarkTextBox.prototype.__CheckValue);e.OnFocus.Add(WaterMarkTextBox.prototype.__RemoveWaterMark);e.__CheckValue();e.Type=Type.WaterMarkTextBox;return e;}
WaterMarkTextBox.prototype.__CheckValue=function(){if(this.value.length==0){this.value=this.__WaterMarkValue;this.setAttribute("style",this.__WaterMarkStyle);this.className=this.__WaterMarkClass;}}
WaterMarkTextBox.prototype.__RemoveWaterMark=function(){if(this.value==this.__WaterMarkValue){this.value="";this.setAttribute("style",this.__OStyle);this.className=this.__OClass;}}
WaterMarkTextBox.prototype.WaterMarkValue=function(value){if(value===undefined){return this.__WaterMarkValue;}
this.__WaterMarkValue=value;this.__CheckValue();return this;}
WaterMarkTextBox.prototype.WaterMarkClass=function(className){if(className===undefined){return this.__WaterMarkClass;}
this.__WaterMarkClass=className;if(this.value==this.__WaterMarkValue){this.value="";}
this.__CheckValue();return this;}
WaterMarkTextBox.prototype.WaterMarkStyle=function(markStyle){if(markStyle===undefined){return this.__WaterMarkStyle;}
this.__WaterMarkStyle=markStyle;this.__CheckValue();return this;}